<?php require_once "menu.php"; ?>
<table width="100%" class="menubar" cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td class="menudottedline" width="40%"><div class="pathway"></div></td>
        <td class="menudottedline" align="right">
            <table cellpadding="0" cellspacing="0" border="0" id="toolbar">
                <tr height="60" valign="middle" align="center">
                    <td>
                        <a class="toolbar" id="addlink" href="javascript:;">
                        <?php echo $html->image('admin/copy_f2.png', array('align' => 'middle', 'border' => 0)); ?><br>Create
                        </a>
                    </td>
                    <td>
                        <a class="toolbar" id="assignlink" href="javascript:;">
                        <?php echo $html->image('admin/security_f2.png', array('align' => 'middle', 'border' => 0)); ?><br>Access
                        </a>
                    </td>
                    <td>
                        <a class="toolbar" id="deletelink" href="javascript:;">
                        <?php echo $html->image('admin/cancel_f2.png', array('align' => 'middle', 'border' => 0)); ?><br>Delete
                        </a>
                    </td>
                    <td>
                        <a class="toolbar" href="#">
                        <?php echo $html->image('admin/help_f2.png', array('align' => 'middle', 'border' => 0)); ?><br>Help
                        </a>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<br>
<br>
<div align="center" class="centermain">
    <div class="main">

        <table class="adminheading">
            <tr>
                <th class="info" rowspan="2" nowrap>Manage Restrictions</th>
            </tr>
        </table>

        <form id="adminForm" name="adminForm" method="post">
        <table class="adminform" style="width: 100%;">
            <tr>
                <td width="80%" valign="top">

                    <div class="error"></div>
                    <table class="adminlist" cellpadding="20">
                    	<tr>
                    		<th colspan="3">Users</th>
                    		<th width="15%" style="text-align: right;">Show Records:&nbsp;<?php echo $form->select('limit', array('20' => '20', '50' => '50', '100' => '100'), $limit, array('id' => 'limitOption')); ?></th>
                    	</tr>
                        <tr bgcolor="#ae1d1d">
                            <td width="1%" class="subheader"><input type="checkbox" id="toggle1" onclick="checkAllId();"></td>
                            <td width="2%" class="subheader" align="left"><?php echo $paginator->sort('#', 'privilegeId', array('style' => 'color: #ffffff;')); ?></td>
                            <td width="15%" class="subheader" align="left"><?php echo $paginator->sort('Privilege Name', 'name', array('style' => 'color: #ffffff;')); ?></td>
                            <td width="%" class="subheader">&nbsp;</td>
                        </tr>

                        <?php
                         if ($data) {
                            foreach($data as $k => $v){
                                $color = (($k/2) == round($k/2)) ? "#efefef" : "#ffffff";
                         ?>
                        <tr bgcolor="<?php echo $color; ?>">
                            <td align="left"><input type="checkbox" id="nt<?php echo $k; ?>" name="data[row][id][]" value="<?php echo $v['Privilege']['privilegeId']; ?>" onclick="isChecked(this.checked);"></td>
                            <td align="left"><?php echo $v['Privilege']['privilegeId']; ?></td>
                            <td align="left">&#187;&nbsp;<?php echo $html->link($v['Privilege']['name'], '/restrictions/restrictiondetails/'.$v['Privilege']['privilegeId']); ?></td>
                            <td align="">&nbsp;</td>
                        </tr>
                        <?php
                            }
                         }
                         ?>

                        <tr>
                            <td colspan="8" align="center">
                                <div class="pagination">
                                <?php
                                 echo $paginator->prev()."&nbsp;";
                                 echo $paginator->numbers();
                                 echo "&nbsp;".$paginator->next();
                                 ?>
                                </div>
                            </td

                    </table>
                </td>
            </tr>
        </table>

        <input type="hidden" name="boxchecked" value="0">
        <input type="hidden" id="flag" name="data[flag]">
        </form>

    </div>
</div>

<script type="text/javascript">
function checkAllId()
{
    var num = '<?php echo $cnt; ?>';
    checkAll(num, 'nt', 'toggle1');
}

$(document).ready(function() {

    var err = "<?php echo $error; ?>";
    $("#error").hide();
    if (err.indexOf('deleted') != -1) {
        alert('Selected privilege has been deleted');
    } else {
        if (err) $("#error").show();
    }

    $("#addlink").click(function () {
        window.location = "<?php echo $html->url('/restrictions/restrictiondetails'); ?>";
    });

    $("#assignlink").click(function () {
    });

    $("#deletelink").click(function () {
        var msg = "Delete selected user?";
        if (confirm(msg)) {
            $("#flag").val("delete");
            $("#adminForm").attr('action', '<?php echo $html->url("/restrictions/restrictionsmgnt")?>');
            $("#adminForm").submit();
        }
    });

    $("#limitOption").change(function () {
        $("#adminForm").attr('action', '<?php echo $html->url("/restrictions/restrictionsmgnt")?>');
        $("#adminForm").submit();
    });

});
</script>